package com.example.myblog.controller;

import com.example.myblog.util.RequestHttp;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * TODO
 * 小说
 * @Author xiaomao
 * @Date 2021/9/19 21:51
 */
@RestController
@RequestMapping("/novel")
public class NovelController {

    @Resource
    RequestHttp requestHttp;
    String url = "http://novel.api.onetapad.com";

    /**
     * @desc: 查询分类列表
     * mtype=0&book_category2Id=888&book_complete=2&book_category_id=15&pageNum=1
     */
    @RequestMapping("/classify")
    public Object classify(String mtype
            ,  String book_category2Id,  String book_complete
            , String book_category_id, String pageNum){

//        System.out.println("12333:"+pageNum);
//        System.out.println("jjjjj:"+book_complete);
        if(pageNum==null) pageNum = "1";
        if(mtype==null) mtype = "0";
        if(book_category2Id==null) book_category2Id = "16";
        if(book_complete==null) book_complete = "2";
        if(book_category_id==null) book_category_id = "15";

        String param = "mtype="+mtype+"&book_category2Id="+book_category2Id+
                "&book_complete="+book_complete+"&book_category_id="+book_category_id+
                "&pageNum="+pageNum;
        String result = requestHttp.sendPost(url+"/billC/classify", param,false);

        return result;
    }

    /**
     * @desc: 详情
     *
     */
    @RequestMapping("/findDetails")
    public Object findDetails(@RequestParam String book_id){
        String param = "book_id="+book_id;
        String result = requestHttp.sendPost(url+"/adviseBook/findDetails", param,false);

        return result;
    }
    /**
     * @desc: 推荐
     *
     */
    @RequestMapping("/areWatching")
    public Object areWatching(@RequestParam String imei){
        String param = "imei="+imei+"&appid=appid";
        String result = requestHttp.sendPost(url+"/adviseBook/areWatching", param,false);

        return result;
    }

    /**
     * @desc: 章节详情
     *
     */
    @RequestMapping("/findChapter")
    public Object findChapter(@RequestParam String book_type, @RequestParam String book_id, @RequestParam String book_category_order){
        String param = "book_type="+book_type+"&book_id="+book_id+"&book_category_order="+book_category_order;
        String result = requestHttp.sendPost(url+"/book/findChapter", param,false);

        return result;
    }

    /**
     * @desc: 章节内容
     *
     */
    @RequestMapping("/findContent")
    public Object findContent(@RequestParam String book_type, @RequestParam String book_id, @RequestParam String chapter_chapterId){
        String param = "book_type="+book_type+"&book_id="+book_id+"&chapter_chapterId="+chapter_chapterId;
        String result = requestHttp.sendPost(url+"/book/findContent", param,false);

        return result;
    }

    /**
     * @desc: 搜索
     *
     */
    @RequestMapping("/search")
    public Object search( @RequestParam String book_name){
        String param = "book_name="+book_name;
        String result = requestHttp.sendPost(url+"/adviseBook/search", param,false);

        return result;
    }
};
